// v-charts组件 https://github.com/elemefe/v-charts
// 折线图
import VeLine from 'v-charts/lib/line'

// 图片懒加载 https://github.com/hilongjw/vue-lazyload
import VueLazyload from 'vue-lazyload'

// 过滤器 https://github.com/freearhey/vue2-filters
import Vue2Filters from 'vue2-filters'

// 一个更好的moment https://github.com/julon/vue-moment-lib
import VueMomentLib from 'vue-moment-lib'

// 剪贴板 https://github.com/Inndy/vue-clipboard2
import VueClipboard from 'vue-clipboard2'

// element-ui https://github.com/ElemeFE/element
import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'

// h-ui组件
import HTheme from './h-theme/index'
import HImage from './h-image/index'
import HIcon from './h-icon/index'
import HBox from './h-box/index'
import HDateRange from './h-date-range/index.vue'
import HCheckboxWeekly from './h-checkbox-weekly/index.vue'
import HRadioWeekly from './h-radio-weekly/index.vue'
import HSelectDaily from './h-select-daily/index.vue'
import HSelectDate from './h-select-date/index.vue'
import HCheckboxPaytype from './h-checkbox-paytype/index.vue'
import HRadioColor from './h-radio-color/index.vue'
import HFilterBox from './h-filter-box/index.vue'
import HUtils from './h-utils'

const components = [
  HTheme,
  HImage,
  HIcon,
  HBox,
  HDateRange,
  HCheckboxWeekly,
  HRadioWeekly,
  HSelectDaily,
  HSelectDate,
  HCheckboxPaytype,
  HRadioColor,
  HFilterBox,
  VeLine
]

const install = function (Vue) {
  if (install.installed) return
  Vue.use(ElementUI)
  Vue.use(VueLazyload)
  Vue.use(Vue2Filters)
  Vue.use(VueMomentLib)
  Vue.use(VueClipboard)
  Vue.use(HUtils)
  components.map(component => {
    Vue.component(component.name, component)
  })
}

// auto install
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  install
}
